If you opened a TS_DIRECTION_RECEIVE port, then use code like this to
acquire input bytes and their arrival times:
{
stamp_t stamps[NBYTES];
unsigned char data[NBYTES];
tsRead(port, &data, &stamps, NBYTES);
int i;
for(i=0; i < NBYTES; i++) {
data[i] contains a byte of data;
stamps[i] contains UST time at which byte arrived;
}
}
A TSport has a queue of (byte,timestamp) pairs whose capacity you specify
with ttttssssSSSSeeeettttQQQQuuuueeeeuuuueeeeSSSSiiiizzzzeeee(3).
For an input port (TS_DIRECTION_RECEIVE), this queue holds the bytes
which have been received but which you have not yet read using ttttssssRRRReeeeaaaadddd(3).
Characters that arrive on a port whose queue is full will be discarded.
If you attempt to read more characters than are currently available on
the queue, then ttttssssRRRReeeeaaaadddd(3) will block until your request can be satisfied.
For an output port (TS_DIRECTION_TRANSMIT), this queue holds the bytes
which you have enqueued using ttttssssWWWWrrrriiiitttteeee(3) but which have not yet been
transmitted. If you attempt to enqueue so much data that this queue
would fill past its capacity, then ttttssssWWWWrrrriiiitttteeee(3) will block until enough
space has become available to enqueue all of your data.
You can determine the number of (byte,timestamp) pairs currently enqueued
on a TSport using ttttssssGGGGeeeettttFFFFiiiilllllllleeeeddddBBBByyyytttteeeessss(3). You can also use
ttttssssSSSSeeeettttFFFFiiiillllllllPPPPooooiiiinnnnttttBBBByyyytttteeeessss(3) and ttttssssGGGGeeeettttFFFFDDDD(3) to get a file descriptor for use in
sssseeeelllleeeecccctttt(2) or ppppoooollllllll(2) which will unblock when a specified amount of data
or space has become available in a TSport.
TS functions which can err return a TSstatus. A return value of
TS_SUCCESS means that the function was successful, otherwise a TS_ERROR_
token is returned to describe the error. See ERROR HANDLING below for
Open a timestamped serial port. Each TSport represents a connection to
one physical serial port in one direction. Each TS_DIRECTION_RECEIVE
TSport will receive its own copy of the data arriving at the physical
serial port. On TS_PROTOCOL_RS232 serial ports, DTR and RTS are always
asserted, and DCD and CTS are ignored. Hanging up the serial line (see
tttteeeerrrrmmmmiiiioooossss(3)) is not currently supported.
ttttssssOOOOppppeeeennnnPPPPoooorrrrtttt(3) can fail in the following cases:
o TS_ERROR_BAD_LIBRARY_CALL if _c_o_n_f_i_g or _r_e_t_u_r_n_P_o_r_t are NULL or invalid.
o TS_ERROR_BAD_LIBRARY_CALL if you had not set the following parameters
of _c_o_n_f_i_g: ttttssssSSSSeeeettttPPPPoooorrrrttttNNNNaaaammmmeeee(3), ttttssssSSSSeeeettttDDDDiiiirrrreeeeccccttttiiiioooonnnn(3), ttttssssSSSSeeeettttQQQQuuuueeeeuuuueeeeSSSSiiiizzzzeeee(3),
ttttssssSSSSeeeettttCCCCffffllllaaaagggg(3), or ttttssssSSSSeeeettttOOOOssssppppeeeeeeeedddd(3).
o TS_ERROR_OPENING_PORT if a parameter specified in _c_o_n_f_i_g is not
supported on the specified serial port, or there is some problem
interfacing with the tserialio driver.
o TS_ERROR_OPENING_PORT if _c_o_n_f_i_g specifies an invalid queuesize (see